/*******************************************************************************
  * Copyright(c) 2023 Levetop Semiconductor Co.,Led. All rights reserved.   
  * @file     tftlcd_spi.h
  * @author   UartTFT Application Team
  * @version  V0.0.1
  * @date     2023-01-09
  * @brief    This file contains the interface initialization and basic
  *           control functions of the TFT.
********************************************************************************/ 

#ifndef _TFTLCD_SPI_H
#define _TFTLCD_SPI_H

#include "data.h"
#include "module_select.h"
#include "lt168.h"

//----------------------spi------------------------------
#if (LT_TFT_PORT == 0)

#define  LCD_RST_RESET   EPORT1->EPDR &=~(1<<5)
#define  LCD_RST_SET     EPORT1->EPDR |= (1<<5)

#define  LCD_CS_RESET    CCM->U32_QSPIGPIOCR.QSPI2_SS_DO = 0
#define  LCD_CS_SET      CCM->U32_QSPIGPIOCR.QSPI2_SS_DO = 1

#define  LCD_RS_CMD      EPORT1->EPDR &=~(1<<1)
#define  LCD_RS_DATA     EPORT1->EPDR |= (1<<1)

#define  LCD_CLK_RESET
#define  LCD_CLK_SET

#define  LCD_SDA_RESET
#define  LCD_SDA_SET

#define  LCD_SDA_READ

//port_init
extern void LCD_SPI_Port_Init(void);
extern uint16_t LCD_SPI_ReadWriteByte(uint32_t TxData);

extern void LCD_RS(uint8_t bit);
extern void LCD_CS(uint8_t bit);
extern void TFT_CommandWrite(uint16_t cmd);
extern void TFT_DataWrite(uint16_t data);
extern uint16_t TFT_DataRead(void);

extern void TFT_pixel_read(uint16_t *buf, uint32_t numpixel);
extern uint32_t TFT_reg_read(uint16_t reg);

extern void LCD_TFT_Init(void);
extern void LT268_TFT_SetWindows(uint16_t XStar,uint16_t yStar,uint16_t Width,uint16_t High);
void TFT_Enter_Sleep(void);
void TFT_Exit_Sleep(void);

extern void LCD_SPI_DMA_Transmit_sameDFS_32(uint32_t dst, uint32_t src, uint8_t DFS, uint32_t numbyte, uint8_t inc);

extern void TFT_Data_Tran(uint8_t *buf, uint32_t numbyte);
extern void TFT_Data_Tran2(uint16_t color, uint32_t numpixel);

#endif

#endif	/* _TFTLCD_SPI_H */
